package com.it.base.thread.pool.MyCustomThreadPool;

import com.it.base.thread.pool.MyCustomThreadPool.CustomRejectedExecution.CustomRejectedExecutionHandler;
import com.it.base.thread.pool.MyCustomThreadPool.ThreadFactory.MyThreadFactory;

import java.util.concurrent.*;

/**
 * 自定义线程池
 */
public class MyCustomThreadPool {
    private static ExecutorService executorService = new ThreadPoolExecutor(2, 5,
            60L, TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(10),
            new MyThreadFactory(),new CustomRejectedExecutionHandler());

    public static void main(String[] args) {
        for (int i=10;i<10000;i++){
            executorService.execute(()->System.out.println(Thread.currentThread().getName()));
        }
    }
}
